package gsp420.math;


import java.awt.event.MouseEvent;

/**
 * a 2 dimensional vector of floats
 * @author michael.vaganov
 */
public class V2F
{
	/**
	 * @param e makes this vector equal to the mouse event's mouse position
	 */
	public void set(MouseEvent e)
	{
		x = e.getX();
		y = e.getY();
	}

	public void set(float a_x, float a_y)
	{
		x = a_x;
		y = a_y;
	}
	public String toString()
	{
		return "("+x+","+y+")";
	}
	public static void main(String[] args)
	{
		V2F a = new V2F(1,1), b = new V2F(2,2);
		a.add(b);
		if(a.x == 3 && a.y == 3)
		{
			System.out.println("SUCCESS!!!");
		}
		else
		{
			System.out.println("fail :(");
		}
	}
	public V2F(float x, float y)
	{
		this.x = x;
		this.y = y;
	}
	public void clear()
	{
		x=0;y=0;
	}
	public V2F()
	{
		this(0,0);
	}
	/** operator+= */
	public void add(V2F a)
	{
		x += a.x;
		y += a.y;
	}
	public V2F product(float f){
		return new V2F(x*f, y*f);
	}
	/** the scalar parts of the vector */
	public float x, y;
}
